import {api} from "../boot/axios.js";

const sendUrl = "/build";
const getUrl = "/getbuild";
const deleteUrl = "/deletebuild";
const updateUrl = "/updatebuild";
const headers = {
  "Content-Type": "application/json",
  "Access-Control-Allow-Origin": "*",
};

export const sendBuildInfo=async (query) => {
  let data = {
    "geometry": [query.lng, query.lat],
    "name": query.name,
  }
  let result = await api.post(sendUrl,data, {
    headers: headers,
  })
  return result
}
export const getBuildInfo = async (geojson) => {
  try {
    let result = await api.post(getUrl, geojson, {
        headers: headers,
      }
    )
    return result
  } catch (error) {
    return error
  }
}
export const deleteBuildInfo = async (id) => {
  try {
    let result = await api.delete(deleteUrl + '/' + id, {
        headers: headers,
      }
    )
    console.log(result)
    return result
  }
  catch (error) {
    return error
    }
}
export const updateBuildInfo = async (id, data) => {
  try {
    let result = await api.put( updateUrl+ '/' + id, data, {
        headers: headers,
      }
    )
    return result
  } catch (error) {
    return error
  }
}


